<?php
namespace app\index\controller;
use think\Db;

class Search extends Base
{
	public function initialize(){
	    parent::initialize();
	}
    public function index()
    {	
		$this->assign('article',['data'=>"",'page'=>""]);
		return $this->fetch();
    }
	public function lists(){
		echo 1;
	}
	protected function getTagArticle($tag_id =null){
		$limit = request()->param('limit');
		$page = request()->param('page');
		$where          = new Where;
		$where['status'] = 1;
		if(!empty($tag_id)){
			$where['tag'] = ['like', '%' . $tag_id . '%'];
		}
		$list = Db::name('article')->where($where)->paginate($limit)->each(function($item, $key){
			$item['url'] = url('article/index',['id'=>$item['id']]);
			$item['tag'] = $this->getTagList($item['tag']);
			return $item;
		});
		$res['data'] = $list->items();
		$res['page'] = $list->render();
		return $res;
	}
}
